package com.xiejr.actuator.socket.listeners;

import com.xiejr.actuator.socket.abstracts.TopicWebsocketHelper;
import com.xiejr.actuator.socket.model.TopicMessage;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @program: socket-actuator-spring-boot-starter
 * @description: 主题消息监听器
 * @author: xjr
 * @create: 2020-07-13 16:15
 **/
@Component
public class TopicSocketListeners implements ApplicationListener<TopicMessage> {
    @Override
    @Async("socketThreadPool")
    public void onApplicationEvent(TopicMessage topicMessage) {
        TopicWebsocketHelper.notifyConsumers(topicMessage.getTopic());
    }
}
